const ExcelJS = require('exceljs');  
  
async function convertExcelData() {  
    // 加载Excel工作簿  
    let workbook = new ExcelJS.Workbook();  
    const filePath = './lotter-test.xlsx';      
    await workbook.xlsx.readFile(filePath); // 替换为你的Excel文件路径  
  
    let worksheet = workbook.getWorksheet(2);  
    const firstSheet = workbook.getWorksheet(1);

    // 假设数据从第二行开始（第一行可能是标题行）  
    worksheet.eachRow(function(row, rowNumber) {  
        // console.log(row)
        if (rowNumber > 1) { // 跳过标题行  
            let cellValue = row.getCell(1).value; // 假设数据在第一列  
            let seats = cellValue.split(',');
            for(const seat of seats) {
                const match = seat.match(/(\d+)区 (\d+)排(\d+)座/); 
                firstSheet.addRow([`${match[1]}区`, match[2], match[3]]) 
                console.log([match[1], match[2], match[3]]);
            }
  
        }  
    });

    try {
        await workbook.xlsx.writeFile(filePath);  

    } catch (error) {
        console.log(first)
    }

}  
  
convertExcelData().catch(err => {  
    console.error('Error processing Excel file:', err);  
});